<!--
  Copyright 2015-2018 the original author or authors.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<div class="card">
  <div class="card-header">
    <h2>
      SMTP configuration
    </h2>
  </div>
  <div class="card-body">
    <div ng-include src="'template/gt-loading-overlay.html'"></div>
    <div ng-include src="'template/gt-http-error-overlay.html'"></div>
    <div ng-form
         gt-form-autofocus-on-first-input
         name="formCtrl"
         style="padding-top: 15px;">
      <div gt-form-group
           gt-label="Host"
           gt-model="config.host"
           gt-disabled="!layout.adminEdit"
           gt-width="20em">
        <div class="help-block">
          SMTP server hostname or IP address.
        </div>
      </div>
      <div gt-form-group
           gt-label="Port"
           gt-model="config.port"
           gt-number="true"
           gt-pattern="pattern.integer"
           gt-disabled="!layout.adminEdit"
           gt-placeholder="25"
           gt-width="7em">
      </div>
      <div class="form-group row">
        <label for="gtConnectionSecurity" class="col-xl-3 gt-form-label-xl">
          Connection security
        </label>
        <div class="col-xl-9">
          <select ng-model="page.connectionSecurity"
                  ng-disabled="!layout.adminEdit"
                  class="custom-select"
                  style="width: auto;"
                  id="gtConnectionSecurity">
            <option value="none">None</option>
            <option value="ssl-tls">SSL/TLS</option>
            <option value="starttls">STARTTLS</option>
          </select>
        </div>
      </div>
      <div gt-form-group
           gt-label="Username"
           gt-model="config.username"
           gt-disabled="!layout.adminEdit"
           gt-width="20em">
      </div>
      <div class="form-group row">
        <label class="col-xl-3 gt-form-label-xl"
               for="password">
          Password
        </label>
        <div class="col-xl-9">
          <input type="password"
                 class="form-control"
                 ng-model="password"
                 ng-disabled="!layout.adminEdit"
                 name="password"
                 id="password"
                 ng-change="onPasswordChange()"
                 ng-click="onPasswordClick()"
                 style="max-width: 20em; display: inline-block">
        </div>
      </div>
      <div gt-form-group
           gt-label="From email address"
           gt-model="config.fromEmailAddress"
           gt-disabled="!layout.adminEdit"
           gt-placeholder="glowroot@{{localServerName}}"
           gt-width="20em">
      </div>
      <div gt-form-group
           gt-label="From display name"
           gt-model="config.fromDisplayName"
           gt-disabled="!layout.adminEdit"
           gt-placeholder="Glowroot"
           gt-width="20em">
      </div>
      <div class="form-group row"
           ng-if="layout.adminEdit">
        <div class="offset-xl-3 col-xl-9">
          <div gt-button
               gt-label="Save changes"
               gt-click="save(deferred)"
               gt-validate-form="formCtrl">
          </div>
        </div>
      </div>
    </div>
    <div ng-form
         class="pt-3"
         ng-if="layout.adminEdit">
      <fieldset class="gt-fieldset">
        <legend class="gt-legend">
          Send test email
        </legend>
        <div class="gt-fieldset-under-normal-form">
          <div class="form-group row">
            <label class="col-xl-3 gt-form-label-xl"
                   for="testEmailRecipient">
              Test email recipient
            </label>
            <div class="col-xl-9">
              <input type="text"
                     class="form-control"
                     ng-model="page.testEmailRecipient"
                     id="testEmailRecipient"
                     style="max-width: 25em; float: left; vertical-align: top; margin-right: 10px; margin-bottom: 10px;">
              <div gt-button
                   gt-btn-class="btn-secondary"
                   gt-label="Send test email"
                   gt-click="sendTestEmail(deferred)"
                   style="vertical-align: top; margin-bottom: 10px;">
              </div>
            </div>
          </div>
        </div>
      </fieldset>
    </div>
  </div>
</div>
<!-- each page with confirmation dialog needs its own confirmation dom so that it is deleted on $destroy -->
<div ng-include="'template/gt-confirmation.html'"></div>
